package com.bwie.list.controller;

import com.bwie.common.domain.po.Food;
import com.bwie.common.result.Result;
import com.bwie.list.service.FoodService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/food")
public class FoodController {
    @Autowired
    private FoodService foodService;


    /**
     * 购物列表
     * @return
     */
    @PostMapping("/findFoodList")
    public Result<List<Food>> findFoodList(){
        List<Food> food =  foodService.findFoodList();
        return Result.success(food);
    }

    /**
     * 新增
     * @param food
     * @return
     */
    @PostMapping("/addFood")
    public Result addFood(@RequestBody Food food){
          foodService.addFood(food);
        return Result.success();
    }

    /**
     * 支付
     * @param foodId
     * @return
     */
    @GetMapping("/delFood")
    public Result delFood(@RequestParam Integer foodId){
        foodService.delFood(foodId);
        return Result.success();
    }

}
